package cn.iocoder.yudao.module.iot.dal.mysql.deviceeventslog;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.iot.dal.dataobject.deviceeventslog.DeviceEventsLogDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.iot.controller.admin.deviceeventslog.vo.*;

/**
 * 设备事件日志 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface DeviceEventsLogMapper extends BaseMapperX<DeviceEventsLogDO> {

    default PageResult<DeviceEventsLogDO> selectPage(DeviceEventsLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DeviceEventsLogDO>()
                .likeIfPresent(DeviceEventsLogDO::getDeviceName, reqVO.getDeviceName())
                .eqIfPresent(DeviceEventsLogDO::getAction, reqVO.getAction())
                .eqIfPresent(DeviceEventsLogDO::getDescription, reqVO.getDescription())
                .eqIfPresent(DeviceEventsLogDO::getDeviceData, reqVO.getDeviceData())
                .betweenIfPresent(DeviceEventsLogDO::getTime, reqVO.getTime())
                .betweenIfPresent(DeviceEventsLogDO::getCreateTime, reqVO.getCreateTime())
                .geIfPresent(DeviceEventsLogDO::getTime, reqVO.getTimeStart())
                .leIfPresent(DeviceEventsLogDO::getTime, reqVO.getTimeEnd())
                .orderByDesc(DeviceEventsLogDO::getId));
    }

    default List<DeviceEventsLogDO> selectList(DeviceEventsLogExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<DeviceEventsLogDO>()
                .likeIfPresent(DeviceEventsLogDO::getDeviceName, reqVO.getDeviceName())
                .eqIfPresent(DeviceEventsLogDO::getAction, reqVO.getAction())
                .eqIfPresent(DeviceEventsLogDO::getDescription, reqVO.getDescription())
                .eqIfPresent(DeviceEventsLogDO::getDeviceData, reqVO.getDeviceData())
                .betweenIfPresent(DeviceEventsLogDO::getTime, reqVO.getTime())
                .betweenIfPresent(DeviceEventsLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DeviceEventsLogDO::getId));
    }



}
